﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Slippor.Common.PluginFramework
{
    public class ConfigAttribute : Attribute, IConfig
    {
        private IConfig _config;
        public ConfigAttribute(Type type, params object[] args)
        {
            if(args == null)
            {
                _config = Activator.CreateInstance(type) as IConfig;
            }
            else
            {
                _config = Activator.CreateInstance(type, args) as IConfig;
            }
        }

        #region IConfigable Members

        public void Update(ref IPlugin plugin, ref object config)
        {
            _config.Update(ref plugin, ref config);
        }

        public bool Config(ref IPlugin plugin, out object config)
        {
            return _config.Config(ref plugin, out config);
        }

        public void Reset(ref IPlugin plugin)
        {
            _config.Reset(ref plugin);
        }
        #endregion
    }
}
